/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.payment.entity;

import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotNull;
import java.util.List;
import com.jeesite.common.collect.ListUtils;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 应付单Entity
 * @author mr
 * @version 2021-03-11
 */
@Table(name="t_ap", alias="a", columns={
		@Column(name="ap_id", attrName="apId", label="应付单ID", isPK=true),
		@Column(name="ap_code", attrName="apCode", label="编号",queryType=QueryType.LIKE),
		@Column(name="supplier_id", attrName="supplierId", label="供应商"),
		@Column(name="date", attrName="date", label="日期"),
		@Column(name="status1", attrName="status1", label="状态"),
		@Column(name="bill_status", attrName="billStatus", label="审批状态"),
		@Column(name="service_order_id", attrName="serviceOrderId", label="服务订单"),
		@Column(name="payment_account", attrName="paymentAccount", label="付款账号"),
		@Column(name="amount", attrName="amount", label="金额"),
		@Column(name="currency", attrName="currency", label="币种"),
		@Column(name="parent_bill_type", attrName="parentBillType", label="前置单据类型"),
		@Column(name="parent_bill_code", attrName="parentBillCode", label="前置单据编号"),
		@Column(name="create_by", attrName="createBy", label="创建者", isUpdate=false, isQuery=false),
		@Column(name="create_date", attrName="createDate", label="创建时间", isUpdate=false, isQuery=false),
		@Column(name="update_by", attrName="updateBy", label="更新者", isQuery=false),
		@Column(name="update_date", attrName="updateDate", label="更新时间", isQuery=false),
		@Column(name="remarks", attrName="remarks", label="备注信息", queryType=QueryType.LIKE),
		@Column(name="uuid", attrName="uuid", label="日记账回填uuid", isQuery=false),
		@Column(name="uuid_old", attrName="uuidOld", label="旧的日记账回填uuid", isQuery=false),
	}, joinTable= {
		@JoinTable(type=Type.LEFT_JOIN, entity= Supplier.class, attrName="supplier", alias="b",
				on="b.supplier_id = a.supplier_id", columns={
				@Column(name="supplier_id", label="供货外商编码", isPK=true),
				@Column(name="supplier_name", label="供货外商名称", isQuery=false),
		}),
		@JoinTable(type=Type.LEFT_JOIN, entity= ServiceOrder.class, attrName="serviceOrder", alias="c",
				on="c.service_order_id =a.service_order_id", columns={
				@Column(name="service_order_id", label="订单id", isPK=true),
				@Column(name="service_order_code", label="订单编码", isQuery=false),
		})
	},orderBy="a.update_date DESC"
)
public class Tap extends DataEntity<Tap> {

	private static final long serialVersionUID = 1L;
	private String apId;		// 应付单ID
	private String apCode;		// 编号
	private String supplierId;		// 供应商
	private Date date;		// 日期
	private String status1;		// 单据状态
	private String billStatus;//审批状态
	private String serviceOrderId;		// 服务订单
	private ServiceOrder serviceOrder;
	private String paymentAccount;		// 付款账号
	private Double amount;		// 金额
	private String currency;		// 币种
	private String parentBillType;		// 前置单据类型
	private String parentBillCode;		// 前置单据id
	private String parentBillCode1;		// 前置单据编号
	private Supplier supplier;
	private List<TapDetail> tapDetailList = ListUtils.newArrayList();// 子表列表
	private TapDetail tapDetail;
	private Double totalAmount;
	private String uuid; //日记账回填uuid
	private String uuidOld; //日记账回填的老的uuid

	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}

	public String getParentBillCode1() {
		return parentBillCode1;
	}

	public void setParentBillCode1(String parentBillCode1) {
		this.parentBillCode1 = parentBillCode1;
	}

	public String getBillStatus() {
		return billStatus;
	}

	public void setBillStatus(String billStatus) {
		this.billStatus = billStatus;
	}

	public TapDetail getTapDetail() {
		return tapDetail;
	}

	public void setTapDetail(TapDetail tapDetail) {
		this.tapDetail = tapDetail;
	}

	public Double getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(Double totalAmount) {
		this.totalAmount = totalAmount;
	}

	public Tap() {
		this(null);
	}

	public Tap(String id){
		super(id);
	}

	public String getApId() {
		return apId;
	}

	public void setApId(String apId) {
		this.apId = apId;
	}

	@Length(min=0, max=100, message="编号长度不能超过 100 个字符")
	public String getApCode() {
		return apCode;
	}

	public void setApCode(String apCode) {
		this.apCode = apCode;
	}

	@NotBlank(message="供应商不能为空")
	@Length(min=0, max=64, message="供应商长度不能超过 64 个字符")
	public String getSupplierId() {
		return supplierId;
	}

	public void setSupplierId(String supplierId) {
		this.supplierId = supplierId;
	}

	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="日期不能为空")
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Length(min=0, max=1, message="状态长度不能超过 1 个字符")
	public String getStatus1() {
		return status1;
	}

	public void setStatus1(String status1) {
		this.status1 = status1;
	}

	@NotBlank(message="服务订单不能为空")
	@Length(min=0, max=64, message="服务订单长度不能超过 64 个字符")
	public String getServiceOrderId() {
		return serviceOrderId;
	}

	public void setServiceOrderId(String serviceOrderId) {
		this.serviceOrderId = serviceOrderId;
	}

	@Length(min=0, max=100, message="付款账号长度不能超过 100 个字符")
	public String getPaymentAccount() {
		return paymentAccount;
	}

	public void setPaymentAccount(String paymentAccount) {
		this.paymentAccount = paymentAccount;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	@Length(min=0, max=2, message="币种长度不能超过 2 个字符")
	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	@Length(min=0, max=2, message="前置单据类型长度不能超过 2 个字符")
	public String getParentBillType() {
		return parentBillType;
	}

	public void setParentBillType(String parentBillType) {
		this.parentBillType = parentBillType;
	}

	@Length(min=0, max=100, message="前置单据编号长度不能超过 100 个字符")
	public String getParentBillCode() {
		return parentBillCode;
	}

	public void setParentBillCode(String parentBillCode) {
		this.parentBillCode = parentBillCode;
	}

	public List<TapDetail> getTapDetailList() {
		return tapDetailList;
	}

	public void setTapDetailList(List<TapDetail> tapDetailList) {
		this.tapDetailList = tapDetailList;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public Date getDate_gte() {
		return sqlMap.getWhere().getValue("date", QueryType.GTE);
	}

	public void setDate_gte(Date date) {
		sqlMap.getWhere().and("date", QueryType.GTE, date);
	}

	public Date getDate_lte() {
		return sqlMap.getWhere().getValue("date", QueryType.LTE);
	}

	public void setDate_lte(Date date) {
		sqlMap.getWhere().and("date", QueryType.LTE, date);
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getUuidOld() {
		return uuidOld;
	}

	public void setUuidOld(String uuidOld) {
		this.uuidOld = uuidOld;
	}
}
